﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Net_Trading;
using Demo.TspDemo.ServiceSSVG;
using Tools.Math.Geo;

namespace Demo.TspDemo
{
    class Worker
    {
        private Thread tr1;
        private delegate void EmptyDelegate();
        public Worker()
        {
          // fen_main ff = new fen_main();
           tr1 = new Thread(GetPositions);
           tr1.Start();
           // ff.DelegateGetPosition()
        
        }

        public void GetPositions()
        {
            while (true)
            {
                using (Service1 serv = new Service1())
                {
                    Singleton s = Singleton.Instance;
                    Position[] p = serv.RecupererPosition();
                    s.Lesposition = new List<GeoCoordinate>();
                 //   s.Lesposition.RemoveRange(0, s.Lesposition.Count);
                    if (p!=null)
                    {
                        for (int i = 0; i < p.Length; i++)
                        {
                            
                            s.Lesposition.Add(new GeoCoordinate(p[i].Lat, p[i].Lon));

                        }
                    }
                    else
                    {
                        s.Lesposition.Clear();
                    }
                }
            }
            Thread.Sleep(100);
        }
    }
}
